
#pragma once

#include <QChartView>
#include <QMouseEvent>
#include <QGraphicsSimpleTextItem>
#include<QVector>
#include<QLineSeries>
#include<QGraphicsEllipseItem>
#include<QGraphicsLineItem>
QT_CHARTS_USE_NAMESPACE

////现程序未使用qchart 以下代码仅供参考
class ChartView : public QChartView
{
    Q_OBJECT

public:
    ChartView(QWidget *parent = nullptr);
    //~ChartView();
    // 保存坐标区域，用于复位
    void saveAxisRange();


protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void wheelEvent(QWheelEvent *event);
    void leaveEvent(QEvent *event);
private:
    QPoint m_lastPoint;
    bool m_isPress = false;

    bool m_ctrlPress;
    bool m_alreadySaveRange;
    double m_xMin, m_xMax, m_yMin, m_yMax;

    QGraphicsLineItem* x_line = nullptr;
    QGraphicsLineItem*y_line= nullptr;
    QLineSeries* serice= nullptr;
    QGraphicsSimpleTextItem* m_coordItem= nullptr;
    QGraphicsEllipseItem* thepoint= nullptr;

};
